#!/bin/bash

source "./config.env"

echo "🔄 正在重启饥荒服务..."

# 尝试停止
./scripts/stop.sh
sleep 1

# 不管停没停掉，直接启动
./scripts/start.sh
sleep 2

# 检查是否启动成功
if pgrep -f "$server_bin" > /dev/null; then
    echo "✅ 服务启动成功"
else
    echo "⚠️ 启动失败，尝试再次启动..."
    ./start.sh
    sleep 2
    if pgrep -f "$server_bin" > /dev/null; then
        echo "✅ 重新启动成功"
    else
        echo "❌ 重新启动仍失败，请手动检查"
        exit 1
    fi
fi
